home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sml_nj / 93src.lha / src / util / list2.sml < prev    next >
Encoding:
Text File  |  1993-01-27  |  468 b   |  22 lines

  1. (* Copyright 1989 by AT&T Bell Laboratories *)
  2. (* list2.sml *)
  3. (* functionals over pairs of lists *)
  4.  
  5. structure List2 = struct
  6.  
  7. fun app2 f ([],_) = ()
  8.   | app2 f (_,[]) = ()
  9.   | app2 f (a::l,b::m) = (f(a,b); app2 f (l,m))
  10.  
  11. fun map2 f ([],_) = []
  12.   | map2 f (_,[]) = []
  13.   | map2 f (a::l,b::m) = f(a,b)::(map2 f (l,m))
  14.  
  15. val zip2 = map2 (fn x => x)
  16.  
  17. fun all2 pred ([],[]) = true
  18.   | all2 pred (a::l,b::m) = pred(a,b) andalso all2 pred (m,l)
  19.   | all2 pred _ = false;
  20.  
  21. end
  22.